<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1">
    <meta content=always name=referrer>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/base_user.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/css-wap/style.css">
    <script src="__STATIC__/js/jquery-1.8.2.js"></script>
    <script src="__STATIC__/js/jquery.cookie.js"></script>
    <title>购物车</title>
    <style>
        input[type=button],input[type=text],input[type=password]{-webkit-appearance:none;outline:none}
    </style>
    <script>
        $(function () {
            if (sessionStorage.getItem('cart_back_url')){
                $('#backPrev').css('display','block');
            }
            window.onbeforeunload = function () {
               sessionStorage.removeItem('cart_back_url');
            };
            $(".wrap-cart .tc .tc1 .handle>div div").click(
                    function () {
                        var h = $(document.body).height();
                        $(".board").height(h + "px");
                        $(".spsx").css({display: "block"});
                    }
            )
            $("input[type='checkbox']").prop('checked',true);
            //结算总数
            var shu = '';
            $('.goods_number').each(function (i,o) {
                if (shu == ''){
                    shu = parseInt($(o).text());
                }else{
                    shu += parseInt($(o).text());
                }
            })
            if (shu != ''){
                $('#settlement').text(shu);
                settlement_goods();
            }
        })
    </script>
    <style>
        .wrap-cart label + .radio {-webkit-appearance: none;background: url("__STATIC__/img_user/1234.png") no-repeat center left;background-size: 14px 14px;padding: 7px;outline:none;display: inline-block;}
        .wrap-cart label + .radio:checked {background: url("__STATIC__/img_user/123.png") no-repeat center right;background-size: 14px 14px;}
        .wrap-cart  .radio + label {-webkit-appearance: none;background: url("__STATIC__/img_user/1234.png") no-repeat center left;background-size: 14px 14px;padding: 7px;display: inline-block;}
        .wrap-cart  .radio:checked + label  {background: url("__STATIC__/img_user/123.png") no-repeat center right;background-size: 14px 14px;}
        .radio {margin-top: 12px;}
        input {background: #F6F6F6}
    </style>
</head>
<body>
<div class="wrap-cart">
    <div class="header">
        <p>购物车</p>
        <img src="__STATIC__/img_user/back.png" class="back" id="backPrev" onclick="back_url()" style="display: none;">
        {if condition="$data"}
        <!--购物车有值得情况才展示-->
        <span><a href="javascript:display_choose();" id="display">编辑</a></span>
        {/if}
    </div>

    <div>
        {if condition="count($data) neq 0 "}
        <form action="{:url('mobile/user_cart/submit_new_attr')}" method="post" id="form" >
        {volist name="data" id='v' key='i'}
        <div class="name _shop_head">
            <!--店铺选择按钮-->
            <div class="choose">
                <label for="choose_{$i}" ></label>
                <input type="checkbox" id="choose_{$i}" class="radio ckAll_{$v[0]->shopGoods->member_id} check_box" onclick="checkBox({$v[0]->shopGoods->member_id})" />
            </div>
            <!--店铺选择按钮结束-->
            <!--店铺名称-->
            <p><a href="javascript:jump_shop({$v[0]->shopGoods->member_id});"><span> {$key}</span>
                <img src="__STATIC__/img_user/next1.png"></a></p>
            <!--店铺名称结束-->
        </div>
        {volist name='v' id='item'}
        <div class="tc" id="goods_details_{$item.id}">
            <!--展示页商品列表-->
                <!--展示页和编辑页商品共同选择按钮开始-->
            <div class="choose">
                <label for="choose_{$item.id}"></label><input id="choose_{$item.id}" type="checkbox" class="radio ck_{$item.shopGoods.member_id} check_box goods_check" value="{$item.id}" onclick="settlement_goods({$item.shopGoods.member_id},{$item.id});">
            </div>
                <!--展示页和编辑页商品共同选择按钮开始-->
                <!--展示页商品-->
            <div class="tc1 default">
                <div class="center" style="height: 100px;">
                    <a href="javascript:jump_goods_details({$item.goods_id});">
                        <img src="/{$item.shopGoods.thumb_img}" onerror=this.src="/static/mobile/img/empty_img.png" ></a>
                    <div>
                        <h4><a href="javascript:jump_goods_details({$item.goods_id});" style="color: black;">{$item.shopGoods.title}</a>
                        </h4>
                        <div class="size" style="margin-top: 5px;">
                            <div  style="padding: 0;">属性规格：<span style="float: none;"><font id="goods_attr_{$item.id}">{if condition="$item.attr"}{$item.attr}{else/}无属性{/if}</font></span></div>
                            <span>×<font class="_number{$item.id} goods_number" >{$item.number}</font></span>
                            <input type="hidden" class="_freight" value="{$item.shopGoods.freight|default=0}"/>
                        </div>
                        <div class="price" style="margin-top: 5px;">
                            <span style="font-size: 12px;">&yen;&nbsp;<font class="_price" style="font-size: 14px;">{$item.price}</font></span>
                        </div>
                    </div>
                </div>
            </div>
                <!--展示页商品结束-->
                <!--商品编辑页面-->
            <div class="tc1 attr_style" style="display: none">
                <h4><a href="javascript:jump_goods_details({$item.goods_id});">{$item.shopGoods.title}</a>
                </h4>
                <div class="handle">
                    <!--购物车id-->
                    <input type="hidden" name="cart_id[]" value="{$item.id}" />
                    <a href="javascript:jump_goods_details({$item.goods_id});">
                        <img src="/{$item.shopGoods.thumb_img}" onerror=this.src="/static/mobile/img/empty_img.png" ></a>
                    <div>
                        <ul>
                            <li class="add" onclick="minus(this,{$item.id})">-</li>
                            <li class="num"><input type="text" class="_num_{$item.id} input_num" onkeyup="num_control(this,{$item.number},{$item.id});" value="{$item.number}" style="width: 100%;outline: none;border: 0;text-align: center" /></li>
                            <li class="add" onclick="plus(this,{$item.shopGoods.id},{$item.id})">+</li>
                        </ul>
                        <!--新数量-->
                        <input type="hidden" name="new_num[]" id="b_{$item.id}" value="{$item.number}" />
                        <div onclick="dialog_goods_attr({$item.shopGoods.id},$(this).siblings('ul').find('.input_num').val())" style="position: relative;">
                            <!--新属性-->
                            <input type="hidden" name="new_attr[]"  id="a_{$item.id}" {if condition="$item.attr"} value="{$item.attr}" {else/} value="" {/if}  />
                            <span>属性规格: <font id="_number_{$item.id}">{if condition="$item.attr"}{$item.attr}{else/}无属性{/if} </font></span>
                            <img src="__STATIC__/img_user/down2.png">
                        </div>
                    </div>
                </div>
            </div>
                <!--编辑页商品-->
        </div>
        {/volist}
        {/volist}
        </form>
        {else/}
        <div class="center" id="empty" style="padding: 0px;">
            <img src="__STATIC__/img_user/gw-tishibiao.png" style="width: 100%;">
        </div>
        {/if}
        <div class="like">
            <p>猜你喜欢</p>
            <ul class="list_group" style="margin-bottom: 0px;">
                {volist name='likeArr' id='v'}
                <li>
                    <a href="javascript:jump_goods_details({$v.id});">
                        <div class="pic">
                            <img src="/{$v.thumb_img}" style="height: 150px;" onerror = "this.src='/static/mobile/img/empty_img.png'" >
                        </div>
                        <h4 class="title">{$v.title}</h4>
                        <div class="price"><span class="yen">￥</span>{$v.price}<span class="sale_num">销量{$v.sale_number}</span></div>
                    </a>
                </li>
                {/volist}
            </ul>
        </div>

    </div>
    <div class="board" onclick="cancel()"></div>
    <div class="spsx" style="bottom:70px;">

    </div>
    <div class="footer">
        {if condition="$data"}
        <!--购物车有值的情况才展示-->
        <div class="all" id="dialog">
            <div class="choose" style="width: 18%;">
                <label for="checkAll"></label>
                <input type="checkbox" class="radio" id="checkAll" onclick="allCk()" style="float:left;margin-right: 5%;margin-top: 14px;"/>
                <span> 全选</span>
            </div>
            <span style="line-height: 42px;float: right;;display: none;" class="all_delete"><span class="settle" onclick="del_all()"> 删除 </span></span>
            <div class="total">
                合计：<span class="price" style="margin-right: 5px">&yen;<span id="_total">0.00</span></span>
                <span class="fare" id="_total_freight" style="display:none;"> 不含运费 </span>
                <span class="settle" onclick="settle()"> 结算(<font id="settlement">0</font>) </span>
            </div>
        </div>
        {/if}
            <ul class="footer_menu_list">
                <li><a href="{:url('mobile/user_port/index')}"><img src="__STATIC__/img-wap/nav5.png"><span>首页</span></a></li>
                <li><a href="{:url('mobile/user_category/index')}?cate_id=recommend"><img src="__STATIC__/img-wap/nav2.png"><span>分类</span></a></li>
                <li class="active"><a href="javascript:cart_check();"><img src="__STATIC__/img-wap/nav7.png"><span>购物车</span></a></li>
                <li><a href="{:url('mobile/user_info/my_shop_index')}"><img src="__STATIC__/img-wap/nav4.png"><span>我的</span></a></li>
            </ul>
    </div>
</div>
<script src="__STATIC__/js/jquery.form.min.js"></script>
<script src="__STATIC__/js/layer_mobile/layer.js"></script>
<script src="__STATIC__/js/cart_price.js"></script>
<script src="__STATIC__/js/attr_dialog.js"></script>
<script>
    function dialog_goods_attr(id, num) {
        var url = "{:url('mobile/user_cart/goods_attr')}";
        attr_dialog(id, url, num);
        $('.spsx').css('display', 'block')
    }
    //返回
    function back_url(){
        var url = sessionStorage.getItem('cart_back_url');
        sessionStorage.removeItem('cart_back_url');
        window.location.href=url;
    }
    //猜你喜欢跳转到商品详情
    function jump_goods_details(id){
        sessionStorage.setItem('goods_url_back',window.location.href);
        window.location.href = "{:url('mobile/user_category/goods_details')}?goods_id="+id;
    }
    //跳转到店铺
    function jump_shop(id) {
        var url = "{:url('mobile/user_category/shop_index')}?shop_id="+id;
        sessionStorage.setItem('shop_back_url',window.location.href);
        window.location.href = url;
    }
    //去结算
    function settle(){
        if (parseInt($('#settlement').text()) > 0){
            //页面选中的商品id
            var cart_id_str = '';
            $('.goods_check:checked').each(function (i,o) {
                if (cart_id_str == ''){
                    cart_id_str = $(o).val();
                }else{
                    cart_id_str += ','+$(o).val();
                }
            })
            if (cart_id_str != ''){   //跳转到确认订单那里
                sessionStorage.setItem('goods_order_yes_url',window.location.href);   //确定订单返回的路径
                window.location.href = "{:url('mobile/user_category/order_yes')}?act=cart&cart_id="+cart_id_str;
            }
        }else{
            layer.open({content:'没有商品可去结算',skin:'msg',time:2});
        };
    }


    //跳转到商品详情页
//    function jump_goods(id){
//        sessionStorage.setItem('goods_url_back',window.location.href);
//        window.location.href = "{:url('mobile/user_category/goods_details')}?goods_id="+id;
//    }
</script>
</body>
</html>